package com.zjdiepu.www.commpent.mapper.zx;

import javax.annotation.Resource;

import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.stereotype.Component;

import com.zjdiepu.www.base.core.BaseMapper;
import com.zjdiepu.www.base.enums.status.BusiStatus;
import com.zjdiepu.www.base.enums.status.CreditQueryStatus;
import com.zjdiepu.www.base.enums.type.DataDicType;
import com.zjdiepu.www.commpent.RedisObjectClient;
import com.zjdiepu.www.model.base.dto.SimpleDataDictionary;
import com.zjdiepu.www.model.zx.dto.ZxCreditQuery;
import com.zjdiepu.www.util.CachedEnums;

/**
 * 项目名称：diepu-parent-biz <br/> 
 * 类名称：ZxCreditQueryVoMapper <br/>  
 * 类描述：征信查询<br/>    
 * 创建人：xiongxiaotun <br/> 
 * 创建时间：2017年4月26日 下午1:33:37  <br/>   
 * 修改人：xiongxiaotun <br/> 
 * 修改时间：2017年4月26日 下午1:33:37   <br/>  
 * 修改备注：    <br/> 
 * @version V1.0   <br/>
 */
@Component
public class ZxCreditQueryVoMapper extends BaseMapper<ZxCreditQuery>{
	@Resource
	private RedisObjectClient redisObjectClient;
	@Override
	public void mapper(RedisConnection redisConnection,ZxCreditQuery m) {
		if(null == m) {
			return;
		}
		Integer busiStatus = m.getBusiStatus();
		m.setBusiStatusDisplay((String)CachedEnums.getValue(busiStatus, BusiStatus.class));
		
		String channelType = m.getChannelType();
		SimpleDataDictionary simpleDataDictionary1 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), channelType, DataDicType.CHANNEL_TYPE.getCode());
		m.setChannelTypeDisplay(simpleDataDictionary1 == null ? "" : simpleDataDictionary1.getName());
		
		String dealerLevel = m.getDealerLevel();
		SimpleDataDictionary simpleDataDictionary2 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), dealerLevel, DataDicType.DEALER_LEVEL.getCode());
		m.setDealerLevelDisplay(simpleDataDictionary2 == null ? "" : simpleDataDictionary2.getName());
		
		String bankCode = m.getBankCode();
		SimpleDataDictionary simpleDataDictionary3 = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), bankCode, DataDicType.LOAN_BANK.getCode());
		m.setBankCodeDisplay(simpleDataDictionary3 == null ? "" : simpleDataDictionary3.getName());
		
		String creditResult = m.getCreditResult();
		SimpleDataDictionary creditResultDic = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), creditResult, DataDicType.CREDIT_RESULT.getCode());
		m.setCreditResultDisplay(creditResultDic == null ? "" : creditResultDic.getName());
		
		String onceCarStatus = m.getOnceCarStatus();
		SimpleDataDictionary onceCarStatusDic = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), onceCarStatus, DataDicType.ONCE_CAR_STATUS.getCode());
		m.setOnceCarStatusDisplay(onceCarStatusDic == null ? "" : onceCarStatusDic.getName());
		
		Integer creditQueryStatus = m.getCreditQueryStatus();
		m.setCreditQueryStatusDisplay((String)CachedEnums.getValue(creditQueryStatus, CreditQueryStatus.class));
		
		String creditPeopleType = m.getCreditPeopleType();
		SimpleDataDictionary creditPeopleTypeDic = redisObjectClient.hGet(redisConnection, SimpleDataDictionary.class.getSimpleName(), creditPeopleType, DataDicType.CREDIT_PEOPLE_TYPE.getCode());
		m.setCreditPeopleTypeDisplay(creditPeopleTypeDic == null ? "" : creditPeopleTypeDic.getName());
		
	}
}
